package com.amigo.online.provider.merchant.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.amigo.online.common.base.service.BaseService;
import com.amigo.online.provider.merchant.mapper.GoodsCommentImgMapper;
import com.amigo.online.provider.merchant.model.entity.GoodsCommentImg;
import com.amigo.online.provider.merchant.service.GoodsCommentImgService;

/**
 * <code>GoodsCommentImgServiceImpl.java</code>
 * <p>
 *
 * </p>
 * <p>
 *
 * @author LuChen
 * @version 1.0
 * @company Amigo
 * @time 2018年12月15日 下午5:31:22
 * @lastUpdate 无
 * </p>
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class GoodsCommentImgServiceImpl extends BaseService<GoodsCommentImg> implements GoodsCommentImgService {

    @Autowired
    private GoodsCommentImgMapper goodsCommentImgMapper;


    @Override
    public boolean insertCommentImg(Long id, List<String> list) {
        if (list == null || list.size() == 0) {
            return true;
        }
        List<GoodsCommentImg> imgList = new ArrayList<>();
        for (String url : list) {
            GoodsCommentImg gc = new GoodsCommentImg();
            gc.setDeleted(0);
            gc.setCommentId(id);
            gc.setImgUrl(url);
            gc.setCreatedTime(System.currentTimeMillis() / 1000);
            imgList.add(gc);
        }
        goodsCommentImgMapper.insertList(imgList);
        return true;
    }

}

